<template>
    <div class="dark:bg-black text-white p-1 bg-log-inner"  >
        <el-row class=" ">
            <el-col :span="24">
                <el-input type="textarea" v-model="logtxt" readonly rows="15"  class="w-full bg-black text-white  text-[0.625rem]" />
            </el-col>
        </el-row>

         <el-row v-show="bd_loading">
            <el-col :span="24">
                 <img src="../assets/img/loading.gif" class="w-full h-2"  />
            </el-col>
         </el-row>
    </div>
  
</template>

<script setup>
import {ref, onMounted, getCurrentInstance, onDeactivated, defineProps} from 'vue';
import { ElMessage } from 'element-plus'
 
const { start_status } = defineProps(['start_status']);

const logtxt = ref("")
const bd_loading = ref(false)

onMounted(() => {
      // 设置定时器，每隔 3 秒执行一次 count 函数
      const intervalId = window.setInterval(count, 1000);
      // 当离开组件时，清除定时器
      onDeactivated(() => {
        window.clearInterval(intervalId);
      });
});

const count = () => {
    if (start_status == 1 || 1) {
        window.pywebview.api.pyWatchdog().then((r) => {
          logtxt.value = r;
        })
    }
};

const changeImgLoading = (status) => {
    bd_loading.value = status;
}


const clearNull = () =>{
    logtxt.value = ''
    window.pywebview.api.pyWatchClear().then((r) => {
      //
    })
}
defineExpose({ changeImgLoading,clearNull })
</script>

<style scoped>
:deep(.el-textarea__inner) {
    background-color: #333;
    color: #fff;
}

.bg-log-inner {
  height: 235px;
}
</style>
